package com.cencat.order.entity;

import com.baomidou.mybatisplus.annotation.*;
import jakarta.validation.constraints.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 订单信息实体类
 * 
 * @author cencat
 * @since 2024-01-20
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("order_info")
public class OrderInfo implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 订单ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 订单号
     */
    @NotBlank(message = "订单号不能为空")
    @Size(max = 32, message = "订单号长度不能超过32个字符")
    @TableField("order_no")
    private String orderNo;

    /**
     * 用户ID
     */
    @NotNull(message = "用户ID不能为空")
    @TableField("user_id")
    private Long userId;

    /**
     * 商家ID
     */
    @NotNull(message = "商家ID不能为空")
    @TableField("merchant_id")
    private Long merchantId;

    /**
     * 订单类型：1-普通订单，2-团购订单，3-秒杀订单
     */
    @NotNull(message = "订单类型不能为空")
    @TableField("order_type")
    private Integer orderType;

    /**
     * 订单状态：0-待付款，1-已付款，2-已发货，3-已送达，4-已完成，5-已取消，6-已退款
     */
    @NotNull(message = "订单状态不能为空")
    @TableField("order_status")
    private Integer orderStatus;

    /**
     * 支付状态：0-未支付，1-已支付，2-已退款，3-部分退款
     */
    @NotNull(message = "支付状态不能为空")
    @TableField("payment_status")
    private Integer paymentStatus;

    /**
     * 物流状态：0-未发货，1-已发货，2-已送达，3-已退货
     */
    @NotNull(message = "物流状态不能为空")
    @TableField("shipping_status")
    private Integer shippingStatus;

    /**
     * 订单总金额
     */
    @NotNull(message = "订单总金额不能为空")
    @DecimalMin(value = "0.00", message = "订单总金额不能小于0")
    @TableField("total_amount")
    private BigDecimal totalAmount;

    /**
     * 商品金额
     */
    @NotNull(message = "商品金额不能为空")
    @DecimalMin(value = "0.00", message = "商品金额不能小于0")
    @TableField("product_amount")
    private BigDecimal productAmount;

    /**
     * 运费
     */
    @TableField("shipping_amount")
    private BigDecimal shippingAmount;

    /**
     * 优惠金额
     */
    @TableField("discount_amount")
    private BigDecimal discountAmount;

    /**
     * 优惠券金额
     */
    @TableField("coupon_amount")
    private BigDecimal couponAmount;

    /**
     * 实付金额
     */
    @TableField("paid_amount")
    private BigDecimal paidAmount;

    /**
     * 退款金额
     */
    @TableField("refund_amount")
    private BigDecimal refundAmount;

    /**
     * 货币类型
     */
    @Size(max = 10, message = "货币类型长度不能超过10个字符")
    @TableField("currency")
    private String currency;

    /**
     * 支付方式：ALIPAY-支付宝，WECHAT-微信，BANK-银行卡，CASH-现金
     */
    @Size(max = 20, message = "支付方式长度不能超过20个字符")
    @TableField("payment_method")
    private String paymentMethod;

    /**
     * 支付时间
     */
    @TableField("payment_time")
    private LocalDateTime paymentTime;

    /**
     * 发货时间
     */
    @TableField("shipping_time")
    private LocalDateTime shippingTime;

    /**
     * 送达时间
     */
    @TableField("delivery_time")
    private LocalDateTime deliveryTime;

    /**
     * 完成时间
     */
    @TableField("completion_time")
    private LocalDateTime completionTime;

    /**
     * 取消时间
     */
    @TableField("cancel_time")
    private LocalDateTime cancelTime;

    /**
     * 取消原因
     */
    @Size(max = 255, message = "取消原因长度不能超过255个字符")
    @TableField("cancel_reason")
    private String cancelReason;

    /**
     * 收货人姓名
     */
    @NotBlank(message = "收货人姓名不能为空")
    @Size(max = 50, message = "收货人姓名长度不能超过50个字符")
    @TableField("receiver_name")
    private String receiverName;

    /**
     * 收货人电话
     */
    @NotBlank(message = "收货人电话不能为空")
    @Size(max = 20, message = "收货人电话长度不能超过20个字符")
    @TableField("receiver_phone")
    private String receiverPhone;

    /**
     * 收货地址
     */
    @NotBlank(message = "收货地址不能为空")
    @Size(max = 255, message = "收货地址长度不能超过255个字符")
    @TableField("receiver_address")
    private String receiverAddress;

    /**
     * 收货省份
     */
    @Size(max = 50, message = "收货省份长度不能超过50个字符")
    @TableField("receiver_province")
    private String receiverProvince;

    /**
     * 收货城市
     */
    @Size(max = 50, message = "收货城市长度不能超过50个字符")
    @TableField("receiver_city")
    private String receiverCity;

    /**
     * 收货区县
     */
    @Size(max = 50, message = "收货区县长度不能超过50个字符")
    @TableField("receiver_district")
    private String receiverDistrict;

    /**
     * 邮政编码
     */
    @Size(max = 10, message = "邮政编码长度不能超过10个字符")
    @TableField("receiver_postcode")
    private String receiverPostcode;

    /**
     * 物流公司
     */
    @Size(max = 100, message = "物流公司长度不能超过100个字符")
    @TableField("logistics_company")
    private String logisticsCompany;

    /**
     * 物流单号
     */
    @Size(max = 50, message = "物流单号长度不能超过50个字符")
    @TableField("logistics_no")
    private String logisticsNo;

    /**
     * 订单备注
     */
    @Size(max = 500, message = "订单备注长度不能超过500个字符")
    @TableField("remark")
    private String remark;

    /**
     * 创建时间
     */
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime updateTime;

    /**
     * 创建人
     */
    @Size(max = 50, message = "创建人长度不能超过50个字符")
    @TableField(value = "create_by", fill = FieldFill.INSERT)
    private String createBy;

    /**
     * 更新人
     */
    @Size(max = 50, message = "更新人长度不能超过50个字符")
    @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
    private String updateBy;

    /**
     * 是否删除：0-未删除，1-已删除
     */
    @TableLogic
    @TableField("deleted")
    private Integer deleted;

    /**
     * 版本号
     */
    @Version
    @TableField("version")
    private Integer version;
}